﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XNA_TD.Shells
{
    public class ATTowerShell : SquarePointSprite, IFixedGameUpdate
    {
        GameObject target;
        float dmg;

        public ATTowerShell(Vector3 pos, GameObject target, float dmg, float scale)
            : base(pos, scale, new Vector4(0, 0, 0, 1), "Solid")
        {
            this.dmg = dmg;
            this.target = target;
        }

        public void FixedGameUpdate()
        {
            var dir = position - target.position;
            if (dir.Length() < 0.2f)
            {
                target.Damage(dmg);
                UnRegister(this);
            }
            dir.Normalize();
            position -= dir * 0.1f;
        }
    }
}
